import 'package:flutter/material.dart';
import 'package:flutterdouban/pages/main/bottom_bar_item.dart';
import 'package:flutterdouban/pages/main/initalize_items.dart';

class JKMainPage extends StatefulWidget {
  static const String routeName = "/mainpage";
  @override
  _JKMainPageState createState() => _JKMainPageState();
}

class _JKMainPageState extends State<JKMainPage> {
  int _currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentIndex,
        children: pages,
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        // 选中的字体大小
        selectedFontSize: 12,
        // 未选中的字体大小
        unselectedFontSize: 12,
        // 选中的字体颜色
        selectedItemColor: Colors.green,
        // 未选中的字体颜色
        unselectedItemColor: Colors.grey,
        // 超过四个的时候必须设置它，不然多出的就会被隐藏掉
        type: BottomNavigationBarType.fixed,
        items: items,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
      ),
    );
  }
}
